<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data" method="post" id="frm">
    <input type="hidden" name="NowPage" id="NowPage" value="{$NowPage}" />
      <div class="table">
       <div class="toolbars">
            <li class="toolbar"><a id="btnSaveAll" href="{$Url}addKeywordReply"  title="添加关键词" target="_self">&nbsp;&nbsp;添加关键词</a></li>
            <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
            <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
            <li class="toolbar" style="display:none"><a id="sortall" onclick="BatchSort()" title="批量修改优先级">优先级</a></li>
        </div>
        <table class="datatable" id="datatable">
            <tr>
                <th width="35px"  nowrap="nowrap">选中</th>
                <th width="55px" >关键词ID</th>
                <th width="100px" >关键词</th> 
                <th width="95px" >使用次数</th>
                <th width="150px" >回复消息类型</th>
                <th>回复消息内容</th>       	
                <th width="60px" >是否启用</th>
                <th width="150px">操作</th>
            </tr>
            <notempty name="KeywordReply">  
                <volist name="KeywordReply" id="b">
                    <tr>
                        <td><input class="checkrow" type="checkbox" name="ReplyID[]" value="{$b.ReplyID}" /></td>
                        <td>{$b.ReplyID}</td>
                        <td style="text-align:left; word-break : break-all">{$b.Keyword}</td>
                        <td >
                        	<b style="text-align:center; color:#0000FF;" id="c{$b.ReplyID}">{$b.Count}</b>
                        	&nbsp;&nbsp;<a onclick="setZero({$b.ReplyID})">[清零]</a>
                        </td>
                        <td><b style="color:{$b.TypeID|WxMenuTypeColor}">{$b.TypeName}</b></td>
                        <td style="text-align:left">
                            <switch name="b.TypeID">
                            <case value="1">{$b.p1|Left=25}</case>
                            <case value="2">显示<b style="color:green; padding:0 3px">{$b.p1|ChannelName}</b>频道前<b style="color:#00F; padding:0 3px">{$b.p2}</b>条信息</case>
                            <case value="3">{$b.p1}</case>
                            <case value="4">打开<b style="color:green; padding:0 3px">{$b.p1|ChannelName}</b>频道主页</case>
                            <case value="5">
                                <empty name="b.p4">
                                    <eq name="b.p1|is_numeric" value="1">
                                         <b style="color:{$b.TypeID|WxMenuTypeColor}">{$b.p1|WxAppName}</b>
                                    <else/>
                                         {$b.p1}
                                    </eq>
                                 <else/>
                                    <b>{$b.p4}</b>
                                </empty>
                            </case>
                            <case value="6"><a href="{$b.p1}" target="_blank">{$b.p1}</a></case>
                            </switch>
                        </td>
                        <td>
                            <eq name="b.IsEnable" value="1">
                                <span style="color:black;cursor:pointer;"  onclick="toggleStatus(this,{$b.ReplyID},'wx_reply')">启用</span>
                            <else/>
                                <span style="color:red;cursor:pointer;"  onclick="toggleStatus(this,{$b.ReplyID},'wx_reply')">禁用</span>
                            </eq>
                        </td>
                        <td class="operator">
                            <a style="float:left" href="{$Url}ModifyKeywordReply/ReplyID/{$b.ReplyID}" id="btnEdit">修改</a>
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="Del({$b.ReplyID})" class="btnDel">删除</a>
                        </td>
                    </tr>
                </volist>
            <else/>
            	<tr><td colspan="8" id="NoData">{$Think.lang.NoDataTip}</td></tr>
            </notempty>                                    
        </table>
        <div class="tfoot">
          <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
        </div>
      </div>
   </form>
</div>
</body>
</html>
<script type="text/javascript">
function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}delKeywordReply/ReplyID/"+id+"/p/{$NowPage}";
		location.href = url;
	}, function () {
		return true;
	});
}

	//批量删除
function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='ReplyID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "{$Url}batchDelKeywordReply");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

//排序
function BatchSort(){
	$.confirm("<div id='icon_common'>确定保存优先级吗?</div>", function () {
		$('#frm').attr("action", "{$Url}batchSortKeywordReply");
		$('#frm').submit();
	}, function () {
		return true;
	});
}	

//关键词次数清0
function setZero(id){
	$.confirm("<div id='icon_common'>确定对关键词使用次数清0吗?</div>", function () {
		var url = "{$Url}zeroKeywordCount/ReplyID/"+id;
		$.get(url, {}, ZeroComplete, "json");
	}, function () {
		return true;
	});
}

//回调函数
function ZeroComplete(data, textStatus){
	if (data.status == 1){
		$("#c"+data.data).text("0");
		SucceedBox(data.info); 
	}else{ //删除失败
		ErrorBox(data.info);
	}
}
</script>